<template>
  <!-- 开始节点 -->
  <promoter v-if="nodeConfig.node_type == 0" v-model="nodeConfig"></promoter>
  <!-- 审批节点 -->
  <approver v-if="nodeConfig.node_type == 1" v-model="nodeConfig"></approver>
  <!-- 抄送节点 -->
  <send v-if="nodeConfig.node_type == 2" v-model="nodeConfig"></send>
  <branch v-if="nodeConfig.node_type == 3" v-model="nodeConfig">
    <template v-slot="slot">
      <node-wrap v-if="slot.node" v-model="slot.node.child_node"></node-wrap>
    </template>
  </branch>

  <node-wrap
    v-if="nodeConfig.child_node"
    v-model="nodeConfig.child_node"
  ></node-wrap>
</template>

<script>
  import approver from './nodes/approver.vue';
  import promoter from './nodes/promoter.vue';
  import branch from './nodes/branch.vue';
  import send from './nodes/send.vue';

  export default {
    props: {
      modelValue: { type: Object, default: () => {} },
    },
    components: {
      approver,
      promoter,
      branch,
      send,
    },
    data() {
      return {
        nodeConfig: {},
      };
    },
    watch: {
      modelValue(val) {
        this.nodeConfig = val;
      },
      nodeConfig(val) {
        this.$emit('update:modelValue', val);
      },
    },
    mounted() {
      this.nodeConfig = this.modelValue;
    },
    methods: {},
  };
</script>

<style></style>
